package com.kevin.eshopcache.controller;

import com.kevin.eshopcache.entity.ProductInfo;
import com.kevin.eshopcache.service.CacheService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: e20160504
 * @date: 2018/11/2
 * @desc
 */

@RestController
@RequestMapping("/cache")
public class CacheController {

    @Resource
    private CacheService cacheService;

    @GetMapping("/save")
    public String saveCache(ProductInfo productInfo){
        cacheService.saveLocalCache(productInfo);
        return "success";
    }

    @GetMapping("/get")
    public ProductInfo getCache(Long id){
        System.out.println("get..........");
        ProductInfo cache = cacheService.getLocalCache(id);
        System.out.println("========" + cache + "===============");
        return cache;
    }
}
